package value;

/**
 * @Author Mucd
 * @ClassName Sorting
 * @Date 2020/12/9/009
 * @Specification Alibaba
 */
public class Sorting {
    public static void main(String[] args) {
        //二维数组打印乘法表
/*        Sorting sort = new Sorting();
        sort.arrays02();
        System.out.println("静态数组👆👆👆👆"+"\n"+"动态数组👇👇👇👇");*/
        Sorting s = new Sorting();
        s.arrays1();
    }

    /**
     * 静态二维数组打印
     */
    public  void arrays02(){
        int[][] arr = {{1,2,3,4,5,6,7,8,9},{1,2,3,4,5,6,7,8,9}};
        //遍历第一组数组
        for (int i = 0;i<arr[0].length;i++){
            for (int j = 0;j<i+1;j++){
                System.out.print((j+1)+"*"+(i+1)+"="+(j+1)*(i+1)+" ");
            }
            System.out.println();
        }
    }

    /**
     * 动态数组打印
     */
    public  void arrays(){
        int[][] arr = new int[9][9];
        //     0             8
        for (int i = 0;i<arr.length;i++){
            //              0<0+1
            for (int j = 0;j<i+1;j++){
                //索引从 0 开始,所以要 +1,否则就是0*0
                System.out.print((j+1)+"*"+(i+1)+"="+(j+1)*(i+1)+"  ");
            }
            System.out.println();
        }
    }
    public void arrays1(){
        int[][] arr = new int[9][9];
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < i+1; j++){
                System.out.print((j+1)+"*"+(i+1)+"="+(j+1)*(i+1)+"  ");
            }
            System.out.println();
        }

    }


}
